<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
    String path5 = request.getContextPath();
%>
<%--练车时间--%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <style type="text/css">
        li span {
            margin-left: 0px;
            cursor: pointer;
        }

        li span:hover {
            color: #427dff
        }

        .modal-data3 {
            visibility: hidden;
            z-index: 1001;
            min-height: 500px;
            margin: 100px auto;
            background-color: #FFFFFF;
            /* border: 1px solid #C80B14;*/
            -moz-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
            -webkit-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
            /*         box-shadow:0 0 10px #cccccc;
            box-shadow: #cccccc; */
            box-shadow: 0 10px 20px #57a1ff inset, 0 -10px 0 #57a0ff inset;
            padding: 5px;
            text-align: center;
            position: fixed;
            left: 22%;
        }

        .head2 tr td, th {
            padding: 0px 10px;
            text-align: center;
        }

    </style>
</head>
<body>
<div id="modal-overlay">

</div>
<div class="modal-data3">
    <div style="height: 60px">
        <ul>
            <li style="text-align: left;margin-left: 60px;height: 40px;line-height: 40px">
                <span style="margin-left: 30px;">名称：</span>
                <span>
				  		 	<input class="cartimeName" type="text">
				  		</span>
                <span>
				  			<button id="findBtn3" class="findBtn2">
				  				查询
				  			</button>
				  		</span>
            </li>
        </ul>
    </div>

    <div style="width:1000px; height:350px; overflow:scroll;">
        <form action="">
            <table class="head2" id="cartimeList" style="width: auto;white-space:nowrap;border-spacing: 0px">
                <tr style="background: #f2f2f2;height: 30px;line-height: 20px;" class="sel">
                    <th style="width: 20px"></th>
                    <th>名称</th>
                    <th>编码</th>
                    <th>简称</th>
                    <th>描述</th>
                    <th>创建时间</th>
                    <th>用户名</th>
                    <th>最后修改时间</th>
                    <th>用户名</th>
                    <th>财务组织</th>
                    <th>车辆类型</th>
                    <th>人数</th>
                    <th>练车完成</th>
                    <th>科目</th>
                </tr>

                <c:forEach items="${exerciseCarPlans}" var="exerciseCarPlan" varStatus="s">
                    <tr>
                        <td><input class="data3-checkbox" type="checkbox" name="coachesfid" style="width: 15px;"
                                   value="${exerciseCarPlan.fid}"/>
                            <input name="coachesname" type="hidden" value="${exerciseCarPlan.fnameL2}"/>
                            <input name="cfqty" type="hidden" value="${exerciseCarPlan.cfqty}"/>
                        </td>
                        <td>${exerciseCarPlan.fnameL2}</td>
                        <td>${exerciseCarPlan.fnumber}</td>
                        <td>${exerciseCarPlan.fsimplename}</td>
                        <td>${exerciseCarPlan.fdescriptionL2}</td>
                        <td>${exerciseCarPlan.fcreatetime}</td>
                        <td>${exerciseCarPlan.createName}</td>
                        <td>${exerciseCarPlan.flastupdatetime}</td>
                        <td>${exerciseCarPlan.updateName}</td>
                        <td>${exerciseCarPlan.cwzzName}</td>
                        <c:if test="${exerciseCarPlan.cfcarsize == 1}">
                            <td>小车</td>
                        </c:if>
                        <c:if test="${exerciseCarPlan.cfcarsize == 2}">
                            <td>大车</td>
                        </c:if>
                        <td>${exerciseCarPlan.cfqty}</td>
                        <c:if test="${exerciseCarPlan.cflcwc == 0}">
                            <td>已完成</td>
                        </c:if>
                        <c:if test="${exerciseCarPlan.cflcwc == 1}">
                            <td>未完成</td>
                        </c:if>
                        <c:if test="${exerciseCarPlan.cfkemu==2}">
                            <td>科目二</td>
                        </c:if>
                        <c:if test="${exerciseCarPlan.cfkemu==3}">
                            <td>科目三</td>
                        </c:if>

                    </tr>
                </c:forEach>


            </table>

        </form>
    </div>

    <div class="page" style="display: none;">
        <ul style="border-bottom: none;">
            <li>
                <span class="indexPage3">首页</span>
                <span class="prevPage3">上一页</span>
                <span class="nextPage3">下一页</span>
                <span class="endPage3">尾页</span>
                <input type="hidden" id="totalPage3" value="${pb3}">
                <input type="hidden" id="index3" value="0">
            </li>
        </ul>
    </div>

    <button class="subtn2" id="subtn3" style="width: 150px;position: absolute;bottom: 35px;font-size: 16px;left: 250px">
        确定
    </button>
    <button class="btn" style="width: 150px;position: absolute;bottom: 35px;font-size: 16px;right: 250px">
        关闭
    </button>


</div>
</body>
<script id="table-template-cartime" type="text/x-handlebars-template">
    {{#isNull sList}}
    <tr style="background: #f2f2f2;height: 30px;line-height: 20px;" class="sel">
        <th style="width: 20px"></th>
        <th>名称</th>
        <th>编码</th>
        <th>简称</th>
        <th>描述</th>
        <th>创建时间</th>
        <th>用户名</th>
        <th>最后修改时间</th>
        <th>用户名</th>
        <th>财务组织</th>
        <th>车辆类型</th>
        <th>人数</th>
        <th>练车完成</th>
        <th>科目</th>
    </tr>
    {{#each sList}}
    <tr>
        <td><input class="data3-checkbox" type="checkbox" name="coachesfid" style="width: 15px;"
                   value="{{fid}}"/>
            <input name="coachesname" type="hidden" value="{{fnameL2}}"/>
            <input name="cfqty" type="hidden" value="{{cfqty}}"/></td>
        <td>{{fnameL2}}</td>
        <td>{{fnumber}}</td>
        <td>{{fsimplename}}</td>
        <td>{{fdescriptionL2}}</td>
        <td>{{fcreatetime}}</td>
        <td>{{createName}}</td>
        <td>{{flastupdatetime}}</td>
        <td>{{updateName}}</td>
        <td>{{cwzzName}}</td>
        {{#compare cfcarsize 1}}
        <td>小车</td>
        {{/compare}}
        {{#compare cfcarsize 2}}
        <td>大车</td>
        {{/compare}}
        <td>{{cfqty}}</td>
        {{#compare cflcwc 0}}
        <td>已完成</td>
        {{/compare}}
        {{#compare cflcwc 1}}
        <td>未完成</td>
        {{/compare}}
        {{#compare kmName 2}}
        <td>科目二</td>
        {{/compare}}
        {{#compare kmName 3}}
        <td>科目三</td>
        {{/compare}}
    </tr>
    {{/each}}

    {{else}}
    <td>没有搜索到您想要的内容!</td>
    {{/isNull}}

</script>
<script>
    //弹出框模版文件
    var myTemplatcartime = Handlebars.compile($("#table-template-cartime").html());

    var cartimeName = $('.cartimeName');

    //点击查找按钮
    $('#findBtn3').click(function () {
        index = 1
        $('#cartimeList').html("<div class='loading'></div>");
        $.ajax({
            url: '<%=path5%>/DrivingSys/getExerciseCarPlan ',
            type: "post",
            data: {
                'pindex': '0',
                'name': cartimeName.val(),
            },
            dataType: "json",
            success: function (res) {
                $('#cartimeList').html(myTemplatcartime(res));
                $('#totalPage3').val(res.pb);
            },
            error: function () {
                alert('Error');
            }
        });

    })

    $('.indexPage3').click(function () {
        var index = 0
        $('#index3').val(0)
        $.ajax({
            url: '<%=path5%>/DrivingSys/getExerciseCarPlan ',
            type: "post",
            data: {
                'pindex': index,
                'name': cartimeName.val(),
            },
            dataType: "json",
            success: function (json) {
                $('#cartimeList').html(myTemplatcartime(json));
            },
            error: function () {
                alert('Error');
            }
        });
    })


    $('.endPage3').click(function () {
        var index = parseInt($('#totalPage3').val())
        $('#index3').val(index)
        $.ajax({
            url: '<%=path5%>/DrivingSys/getExerciseCarPlan ',
            type: "post",
            data: {
                'pindex': index,
                'name': cartimeName.val(),
            },
            dataType: "json",
            success: function (json) {
                $('#cartimeList').html(myTemplatcartime(json));
            },
            error: function () {
                alert('Error');
            }
        });
    })


    $('.nextPage3').click(function () {
        var total = parseInt($('#totalPage3').val())
        if ($('#index3').val() < total) {
            var index = $('#index3').val() - 0 + 1
            $('#index3').val(index)
            $.ajax({
                url: '<%=path5%>/DrivingSys/getExerciseCarPlan ',
                type: "post",
                data: {
                    'pindex': index,
                    'name': cartimeName.val(),
                },
                dataType: "json",
                success: function (json) {
                    $('#cartimeList').html(myTemplatcartime(json));
                },
                error: function () {
                    alert('Error');
                }
            });
        } else {
            alert("已经到尾页了！")
        }
    })


    $('.prevPage3').click(function () {
        if ($('#index3').val() != '0') {
            var index = $('#index3').val() - 0 - 1
            $('#index3').val(index)
            $.ajax({
                url: '<%=path5%>/DrivingSys/getExerciseCarPlan ',
                type: "post",
                data: {
                    'pindex': index,
                    'name': cartimeName.val(),
                },
                dataType: "json",
                success: function (json) {
                    $('#cartimeList').html(myTemplatcartime(json));
                },
                error: function () {
                    alert('Error');
                }
            });
        } else {
            alert("已经是首页了")
        }
    })

    //回填练车时间
    $('#subtn3').click(function () {
            var coachesname = "";
            var coachesid = "";
            var cfqty = "";

            $('input:checkbox[name=coachesfid]:checked').each(function (i) {
                coachesid = $(this).val();
                coachesname = $(this).next().val();
                cfqty = $(this).next().next().val();
            });
            if (coachesid == "") {
                alert('请选择练车时间信息！');
                return false;
            }
            //如果不存在重置函数 说明 这里不需要清空 练车时间所造成的 影响
            if (typeof addStu !== "function") {
                _this.val(coachesname)
                _this.next('input[name=cflcsjid]').val(coachesid)
                _this.next().next('input[name=cfqty]').val(cfqty)
                $('#modal-overlay').css('visibility', 'hidden')
                $('.modal-data3').css('visibility', 'hidden')
                return false;
            }

            if ($('.cflcsjid').val() != coachesid && $('.cflcsjid').val() != "") {
                $.messager.confirm('提示', '此操作将会清空列表信息！', function (r) {
                    if (r) {
                        var tr_len = $("#tablejl tr").length;
                        for (var l = 0; l < tr_len - 1; l++) {
                            console.log(l)
                            $("#tablejl tr:last").remove();
                        }
                        addStu()
                        _this.val(coachesname)
                        _this.next('input[name=cflcsjid]').val(coachesid)
                        _this.next().next('input[name=cfqty]').val(cfqty)
                    }
                    else {
                        return false;
                    }
                })
            } else {

                _this.val(coachesname)
                _this.next('input[name=cflcsjid]').val(coachesid)
                _this.next().next('input[name=cfqty]').val(cfqty)
            }
            $('#modal-overlay').css('visibility', 'hidden')
            $('.modal-data3').css('visibility', 'hidden')
        }
    )
    ;


    //单击选中
    $(document).on('click', '#cartimeList tr td', function () {
        $('input:checkbox:first-child:checked').each(function (i) {
            $(this).removeAttr("checked");
        });
        if ($(this).parent().find("input:checkbox").is(':checked')) {
            $(this).parent().find("input:checkbox").removeAttr("checked");
        } else {
            $(this).parent().find("input:checkbox").attr("checked", ":checked")
        }
    })

    //双击
    $(document).on('dblclick', '#cartimeList tr td:not(td:first-child)', function () {
        $(this).parent().find("input:checkbox").attr("checked", ":checked")
        $('#subtn3').click();
    })

</script>
</html>